package com.pencilisland.pay.mgt.console.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.pencilisland.pay.mgt.console.shiro.ShiroUser;

/**
 * 系统用户表
 * 
 * @author Breeze
 *
 */
@Entity
@Table(name = "SYS_USER")
public class SysUser implements ShiroUser,Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name="USER_ID")
	protected Long userId;

	/**
	 * 系统自动编号，按照组织机构层级编码
	 */
	@Column(name="USER_CODE",length=50)
	private String userCode;
	/**
	 * 员工编号,自定义
	 */
	@Column(name="USER_NUMBER",length=50)
	private String userNumber;
	/**
	 * 姓名
	 */
	@Column(name="USER_NAME",length=100)
	private String userName;
	/**
	 * 所属机构
	 */
	@Column(name="ORG_ID")
	private Long orgId;
	/**
	 * 登录用户名
	 */
	@Column(name="LOGIN_NAME",length=50)
	private String loginName;
	/**
	 * 登录密码
	 */
	@Column(name="PASSWORD",length=50)
	private String password;
	/**
	 * 所属机构ID路径
	 */
	@Column(name="ORG_ID_PATH",length=400)
	private String orgIdPath;
	/**
	 * 所属机构名称路径
	 */
	@Column(name="ORG_NAME_PATH",length=400)
	private String orgNamePath;
	/**
	 * 状态
	 */
	@Column(name="STATUS",length=20)
	private String status;
	/**
	 * 性别
	 */
	@Column(name="SEX",length=20)
	private String sex;
	/**
	 * 电子邮件
	 */
	@Column(name="EMAIL",length=20)
	private String email;
	/**
	 * 创建日期
	 */
	@Column(name="CREATE_TIME",length=20)
	private String createTime;
	
	@ManyToOne
	@JoinColumn(name="ORG_ID",updatable=false,insertable=false)
	private SysOrg org;

	public String getUserCode() {
		return userCode;
	}

	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}

	public String getUserNumber() {
		return userNumber;
	}

	public void setUserNumber(String userNumber) {
		this.userNumber = userNumber;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Long getOrgId() {
		return orgId;
	}

	public void setOrgId(Long orgId) {
		this.orgId = orgId;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getOrgIdPath() {
		return orgIdPath;
	}

	public void setOrgIdPath(String orgIdPath) {
		this.orgIdPath = orgIdPath;
	}

	public String getOrgNamePath() {
		return orgNamePath;
	}

	public void setOrgNamePath(String orgNamePath) {
		this.orgNamePath = orgNamePath;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getCreateTime() {
		return createTime;
	}

	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long id) {
		this.userId = id;
	}

	public SysOrg getOrg() {
		return org;
	}

	public void setOrg(SysOrg org) {
		this.org = org;
	}

	@Override
	public boolean isDisabled() {
		return !"0".equals(getStatus());
	}

	@JsonIgnore
	@Override
	public Object getRealUser() {
		return this;
	}

	@Override
	public byte[] getSaltBytes() {
		// TODO Auto-generated method stub
		return null;
	}

}
